import Dep from './dep.js'
class Watcher {
	constructor(vm, exp, cb) {
		this.cb = cb
		this.vm = vm
		this.exp = exp
		this.value = this.getter(exp)
		const dep = new Dep(exp, this)
	}
	update() {
		this.run()
	}
	run() {
		var value = this.getter(this.exp)
		var oldVal = this.value
		if (value !== oldVal) {
			this.value = value
			this.cb(value, oldVal)
		}
	}
	getter(exp) {
		return this.vm[exp]
	}
}
export default Watcher